package com.k2data.k2app.rest;

import com.k2data.k2app.domain.deviceRest.Event;
import com.k2data.k2app.domain.deviceRest.MonitorLimitValue;
import com.k2data.k2app.rest.domain.RectList;
import com.k2data.k2app.rest.domain.RectObject;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDate;

/**
 * Created by clb on 17-6-15.
 */
@Component
@FeignClient(value = "K2ALPHA-DEVICE-V1", fallback = DeviceClientFallbackV2.class)
public interface DeviceClientV2{
	@RequestMapping(method = RequestMethod.GET, value = "/devices")
	RectList getAllDevices(@RequestParam("pageNum") Integer pageNum, @RequestParam("pageSize") Integer pageSize, @RequestParam("deviceNo")String deviceNo);

	@RequestMapping(method = RequestMethod.GET,value = "/customers/{id}/devices")
	RectList getDeviceByCustomer(@PathVariable("id") Long id);

	@RequestMapping(method = RequestMethod.GET, value = "/devices/{id}")
	RectObject getDeviceById(@PathVariable("id") Long id);

	@RequestMapping(method = RequestMethod.PUT, value = "/devices/{id}")
	RectObject updateDevice(@PathVariable("id") Long id,Object device);

	@RequestMapping(method = RequestMethod.GET, value = "/templates/devices")
	RectList getTemplateDeviceById(@RequestParam("id") Long id);

	@RequestMapping(method = RequestMethod.GET, value = "/templates/monitors/points/{id}")
	RectList getTemplatePointById(@PathVariable("id") Long id);

	@RequestMapping(method = RequestMethod.GET, value = "/devices/points/{id}")
	RectObject getDevicePointById(@PathVariable("id") Long id);

	@RequestMapping(method = RequestMethod.GET, value = "/devices/points")
	RectList getDevicePoint(@RequestParam("root_id") Long root_id,
							@RequestParam("monitorPointId") Long monitorPointId,
							@RequestParam("channelId") Integer channelId,
							@RequestParam("isGroup") boolean isGroup);

	@RequestMapping(method = RequestMethod.GET, value = "/devices/points")
	RectList getDevicePointGroup(@RequestParam("root_id") Long root_id,
							@RequestParam("monitorPointId") Long monitorPointId,
							@RequestParam("channelId") Integer channelId,
							@RequestParam("isGroup") boolean isGroup,
						    @RequestParam(value = "groupType",required = false) Integer groupType);

	@RequestMapping(method = RequestMethod.GET, value = "/templates/monitors/variables/{id}")
	RectList getTemplateVariablesById(@PathVariable("id") Long id);

	@RequestMapping(method = RequestMethod.GET, value = "/devices/monitors/variables/{id}")
	RectList getDeviceVariablesById(@PathVariable("id") Long id);

	@RequestMapping(method = RequestMethod.GET, value = "/customers")
	RectList getCustomers(
			@RequestParam(value = "date", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate date,
			@RequestParam(value = "location", required = false) String location,
			@RequestParam(value = "industry", required = false) String industry,
			@RequestParam(value = "customerType", required = false) String customerType,
			@RequestParam(value = "dataSource", required = false) String dataSource,
			@RequestParam(value = "owner", required = false) String owner,
			@RequestParam(value = "status", required = false) String status,
			@RequestParam(value = "userId", required = false) Long userId,
			@RequestParam(value = "customerNo", required = false) String customerNo,
			@RequestParam(value = "pageNum", required = false) Integer pageNum,
			@RequestParam(value = "pageSize", required = false) Integer pageSize,
			@RequestParam(value = "name", required = false) String name);

	@RequestMapping(method = RequestMethod.GET, value = "/customers/{id}")
	RectObject getCustomerById(@PathVariable("id") Long id);

	@RequestMapping(method = RequestMethod.POST, value = "/events1/maintenance")
	RectObject addEvent(@RequestBody Event event);

	@RequestMapping(method = RequestMethod.PUT, value = "/devices/status")
	void changeStatus(@RequestParam("deviceNo") String deviceNo,
					  @RequestParam("status") String status);

	@RequestMapping(method = RequestMethod.GET, value = "/devices/monitors/limits")
	RectList getDeviceLimitValues( @RequestParam(value = "deviceId", required = false) Long deviceId,
								   @RequestParam(value = "monitorPointId", required = false) Long monitorPointId,
								   @RequestParam(value = "variableId", required = false) Long variableId,
								   @RequestParam(value = "deviceNo", required = false) String deviceNo,
								   @RequestParam(value = "channelId", required = false) Integer channelId,
								   @RequestParam(value = "level", required = false) Integer level,
								   @RequestParam(value = "isTemplateVariable",required = false) boolean isTemplateVariable);

	@RequestMapping(method = RequestMethod.PUT, value = "/devices/monitors/limits/{id}")
	RectObject updateMonitorLimit(@PathVariable("id") Long id,
								  @RequestBody MonitorLimitValue limitValue,
								  @RequestParam(value = "limit2kmx",required = false) boolean limit2kmx);

	@RequestMapping(method = RequestMethod.GET, value = "/contacts/{id}")
	RectObject getContactById(@PathVariable("id") Long id);

}
